#include "StdAfx.h"
#include "Movable.h"

#include "SceneNode.h"

using namespace Common;
using namespace RenderSystem;

Movable::Movable(void)
	:m_pAttachedSceneNode( NULL )
{
}


Movable::~Movable(void)
{
}

void Movable::AttachTo( SceneNode* pAttachNode )
{
	if( m_pAttachedSceneNode == pAttachNode )
		return;
	
	//maybe notify the listeners
	m_pAttachedSceneNode = pAttachNode;
}

SceneNode* Movable::GetAttachNode( void ) const
{
	return m_pAttachedSceneNode;
}

void Movable::SetVisible( bool bVisible )
{
	m_bVisible = bVisible;
}

bool Movable::GetVisible( void ) const
{
	return m_bVisible;
}

const Common::AxisAlignedBox& Movable::GetBoundingBox( bool bWorldSpace )
{
	if( bWorldSpace )
	{
		SceneNode* pAttached = this->GetAttachNode();
		if( pAttached != NULL )
			m_AABB.transformAffine( pAttached->GetWorldTransformation() );
	}
	return m_AABB;
}
